<?php

namespace teamug;

/* 
 * Shove all your application settings in here, and declare your app's structure
 * Settings are made available by an instance
 *
 */

Class Config {

  private static $appSettings = array();

  
  public function __get($name) {
    
    if (\array_key_exists($name, self::$appSettings)) {
      return self::$appSettings[$name];
    } else {
      \trigger_error(get_class($this)." has no setting '$name'");
      return null;
    }
  }
  
  
  /**
   * Add one of your app's settings
   * 
   * @param string $name Key name. Eg 'google_track_code'
   * @param mixed $value Value. Eg 'AC-348764D'
   */
  public static function add($name, $value) {
    self::$appSettings[$name] = $value;
    if (Dev::$narration) Dev::narrate("Adding config setting '$name'");
  }

   /**
   * Add several of your apps settings
   * 
   * @param array $settings Assoc array of name=>value. Eg 'pos'=>22, 'pos_name'=>'my_shop'
   */
  public static function addByAssoc($settings) {
    self::$appSettings = \array_merge(self::$appSettings, $settings);
    if (Dev::$narration) Dev::narrate('Adding config settings (unspecified)');
  }
 
}